import 'package:flutter/material.dart';
import 'package:flutterdemo/dart/demo.dart';

class ButtonWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new ButtonWidgetState();
  }
}

class ButtonWidgetState extends State<ButtonWidget> {
  bool _checkboxSelected = true; //维护复选框状态
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        title: Text(
          "button",
          textAlign: TextAlign.center,
        ),
      ),
      body: new Column(
        textDirection: TextDirection.ltr,
        children: <Widget>[
          RaisedButton(
            child: Text("RaisedButton"),
            onPressed: () {
              print("onPressed RaisedButton");
              test();
            },
          ),
          FlatButton(
            child: Text("FlatButton"),
            onPressed: () {
              print("onPressed FlatButton");
            },
          ),
          FlatButton.icon(
            icon: Icon(Icons.add),
            label: Text("FlatButton"),
            onPressed: () {
              print("onPressed FlatButton");
            },
          ),
          OutlineButton(
            child: Text("OutlineButton"),
            onPressed: () {
              print("onPressed OutlineButton");
            },
          ),
          IconButton(
            icon: Icon(Icons.thumb_up),
            onPressed: () {
              print("onPressed IconButton");
            },
          ),
          FlatButton(
            color: Colors.blue,
            highlightColor: Colors.blue[700],
            colorBrightness: Brightness.dark,
            splashColor: Colors.grey,
            child: Text("FlatButton"),
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(20.0)),
            onPressed: () {},
          ),
          Row(
            children: <Widget>[
              RaisedButton.icon(
                onPressed: _checkboxSelected ? () {} : null,
                icon: Icon(Icons.remove_red_eye),
                label: Text("RaisedButton.icon"),
              ),
              Checkbox(
                  value: _checkboxSelected,
                  activeColor: Colors.red,
                  onChanged: (check) {
                    setState(() {
                      _checkboxSelected = check;
                    });
                  }),
            ],
          ),
        ],
      ),
    );
  }

  void test() {
    //测试
    Demo demo = Demo();
    demo.demo();
  }
}
